# Definition for a binary tree node.
class TreeNode:
    def __init__(self, x):
        self.val = x
        self.left = None
        self.right = None

class Solution:
    def rightSideView(self, root: TreeNode):
        if root is None:
            return []
        r = []
        queue = [root]
        while queue:
            r.append(queue[-1].val)
            tmp = []
            for i in queue:
                if i.left:
                    tmp.append(i.left)
                if i.right:
                    tmp.append(i.right)
            queue = tmp
        return r

if __name__ == '__main__':
    so = Solution()
    s = 3
    r = so.hammingWeight(s)
    print(r)
